#include <iostream>
#include "vertex.h"
#include "face.h"
#include "loop.h"
#include "solid.h"

Vertex::Vertex(unsigned int _id, Point& _p, HalfEdge* _he) : id(_id), coord(_p), he(_he){
    selected = false;
}

Vertex::Vertex(unsigned int _id, Point& _p) : id(_id), coord(_p){
    selected = false;
    he = NULL;
}

Vertex::~Vertex(){
}

void Vertex::setPoint(Point& _p){
    coord = _p;
}

void Vertex::setHE(HalfEdge *_he){
    he = _he;
}

unsigned int Vertex::getID(){
    return id;
}

Point Vertex::getPoint(){
    return coord;
}

double *Vertex::getPointVector(){
    return coord.intoVector();
}

HalfEdge *Vertex::getHE(){
    return he;
}

void Vertex::scale(double _s){
    Point p = he->getLoop()->getFace()->getSolid()->getBoundingBoxCenter();

    coord = coord + ((coord - p).normalization()*_s);

//    Face *f;
//    HalfEdge *he1 = he;
//    do{
//        f = he->getLoop()->getFace();
//        if (f->isBezier()) f->resetBezier();
//        he1 = he1->getTwin()->getNext();
//    }while (he1 != he);
}

void Vertex::translate(Point _t){
    coord = coord + _t;

//    Face *f;
//    HalfEdge *he1 = he;
//    do{
//        f = he->getLoop()->getFace();
//        if (f->isBezier()) f->resetBezier();
//        he1 = he1->getTwin()->getNext();
//    }while (he1 != he);
}

void Vertex::select(bool _s){
    selected = _s;
}

bool Vertex::isSelected(){
    return selected;
}
